package com.wuwangfu.stream;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.NumberSequenceIterator;

/**
 * @Author jcshen
 * @Date 2023-02-21
 * @PackageName:com.wuwangfu.stream
 * @ClassName: DFromParCollection
 * @Description: TODO
 * @Version 1.0
 *
 * fromParallelCollection多并行度，有限数据流，用于实验。
 *
 * 单并行度的Source直接实现了SourceFunction接口
 * 多并行度的Source，可以实现RichParallelSourceFunction或ParallelSourceFunction接口
 */
public class DFromParCollection {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<Long> nums = env.fromParallelCollection(new NumberSequenceIterator(1L, 20L), Long.class);

        System.out.println(nums.getParallelism());

        nums.print();
        env.execute();
    }
}
